﻿using System;
using System.Windows;
using WickedFlame.Core.Shapes;

namespace WickedFlame.Core.State
{
    [Serializable]
    internal class SCurveMemento : ShapeMemento
    {
        Point _startPoint;
        Point _endPoint;
        Point _startCurvePoint;
        Point _endCurvePoint;

        public override void SaveProperties(VectorShape shape)
        {
            base.SaveProperties(shape);

            SCurveShape c = shape as SCurveShape;
            if (c != null)
            {
                _startPoint = c.StartPoint;
                _endPoint = c.EndPoint;
                _startCurvePoint = c.StartCurvePoint;
                _endCurvePoint = c.EndCurvePoint;
            }
        }

        public override void ResetProperties(VectorShape shape)
        {
            base.ResetProperties(shape);

            SCurveShape c = shape as SCurveShape;
            if (c != null)
            {
                c.StartPoint = _startPoint;
                c.EndPoint = _endPoint;
                c.StartCurvePoint = _startCurvePoint;
                c.EndCurvePoint = _endCurvePoint;
            }
        }

        public override VectorShape GenerateShape()
        {
            var shape = new SCurveShape();
            shape.ResetState(this);

            return shape;
        }
    }
}
